<template>
	<view class="container">
		<t-bar-back></t-bar-back>
		<view class="header-box flex-column">
			<!-- style=" background-image: url(../../static/images/share.png);background-size:750rpx 750rpx;background-repeat:no-repeat;"> -->
			<image :src="$IMG_URL+'/imgs/share/business_share.png'" style="width: 750rpx; height: 750rpx;"></image>
		</view>
		<view class="body">
			<view class="flex-row share-title">
				<view class="flex-row">我的好友</view>
				<view class="flex-row share-success">成功邀请<text class="flex-row">{{shareSuccess}}</text>人</view>
			</view>
			<view class="data-list flex-column">
				<t-empty v-if="list.length == 0" tipText="空空如也~" marginTop="150rpx"></t-empty>
				<block v-for="(item,index) in list" :key="index">
					<view class="list-item flex-row">
						<view class="item-type flex-row">
							<image class="share-avatar" mode="aspectFill"
								:src="item.avatar ? item.avatar : '../../static/images/avatar.png'"></image>
							<view class="flex-row">{{item.nickname}}</view>
						</view>
						<view class="item-type  type-date ">{{item.jointime_text}}</view>
					</view>
				</block>
			</view>
		</view>
		<view class="pop-box">
			<uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
				<t-share></t-share>
			</uni-popup>
		</view>
		<view class="sub">
			<button @tap.stop="showShare">分享</button>
		</view>
	</view>
</template>

<script>
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	export default {
		data() {
			return {
				index: 0,
				requestIng: false,
				page: 1,
				list: [],
				shareSuccess: 0,
				top_height: 0
			}
		},
		computed: {
			...mapGetters(['userInfo'])
		},
		onLoad() {
			/* let that = this;
			uni.getSystemInfo({
				success(res) {
					console.log('r', res)
					that.top_height = res.statusBarHeight; //data中 声明 top_height:0 
				}
			}); */
		},
		onShow() {
			this.init()
		},
		methods: {
			jump(url) {
				this.$util.jump(url)
			},
			change(e) {
				console.log('当前模式：' + e.type + ',状态：' + e.show);
			},
			showShare() {
				// this.$refs.popup.open('bottom')
				this.$refs.share.open()
			},
			init() {
				this.page = 1;
				this.index = 0;
				this.getList(1)
			},
			checkTab(index) {
				console.log(index)
				this.index = index;
				this.page = 1;
				this.getList(this.page)
			},
			async getList(page) {
				let that = this;
				that.page = page
				let requestData = {
					page: page
				};
				that.$util.loading('加载中');
				return new Promise((resolve, reject) => {
					that.$http('user.shareData', requestData).then(async res => {
							console.log('商品列表', res)
							that.requestIng = false
							uni.hideLoading()
							if (res.code === 1) {
								that.shareSuccess = res.data.totalNum;
								if (requestData.page == 1) {
									that.list = res.data.list
								} else {
									that.list = that.list.concat(res.data.list)
								}
								if (res.data?.length > 0) {
									console.log('页码增加')
									that.page = that.page + 1
								}
								resolve(res.data);
							} else {
								resolve(false);
							}
						})
						.catch(async err => {
							that.requestIng = false
							uni.hideLoading()
							resolve(false);
						})
				});
			},
		},
		/**
		 * 上拉加载
		 */
		onReachBottom() {
			console.log('onReachBottom');
			!this.requestIng && (this.requestIng = true, this.getList(this.page))
		},
	}
</script>

<style lang="scss">
	.container {
		background: #eee;
		min-height: 100vh;
		position: relative;



		.flex-column {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}

		.flex-row {
			display: flex;
			justify-content: center;
			align-items: center;
		}

		.header-box {
			width: 100vw;
			// height: 400rpx;
			height: 750rpx;
			// position: fixed;
			z-index: 1;
			top: 0;
			left: 0;


			.header {
				background: #FF9000;
				// height: 300rpx;
				height: 100%;
				width: 100%;
				color: #fff;
				justify-content: flex-start;

				&-item {
					width: 86%;
					justify-content: space-between;
					height: 130rpx;

					&-child {
						font-size: 40rpx;
						font-weight: 600;
					}

					.child-btn {
						width: 50%;
						justify-content: space-between;

						button {
							border: 1px solid #fff;
							border-radius: 50rpx;
							width: 130rpx;
							height: 60rpx;
							font-weight: 400;
						}

						.recharge {
							background: #fff;
							color: #FF9000;
						}
					}
				}

				.money-box {
					flex: 1;
					align-items: flex-start;
					box-sizing: border-box;
					height: 100%;
					justify-content: space-around;

					.money-tip {
						font-size: 24rpx;
						font-weight: 400;
					}

					.money-num {
						font-size: 50rpx;
					}
				}
			}

			.tab-box {
				color: #666;
				background: #fff;
				height: 100rpx;
				width: 100%;

				.tab {
					flex: 1;
					height: 100%;
				}

				.tab-active {
					color: #333;
					font-size: 36rpx;
					font-weight: 700;

					.fot {
						width: 60rpx;
						height: 4px;
						background: #FF9000;
						margin-top: 10rpx;
					}
				}
			}
		}

		.body {
			// background: red;
			// top: 400rpx;
			// border-radius: 20px 20px 0 0;
			// height: 70vh;
			// width: 100vw;
			// margin-top: 400rpx;
			background: #fff;
			position: absolute;
			top: 700rpx;
			width: 92%;
			// margin-left: 4%;
			z-index: 2;
			margin: 0 4% 100rpx;
			border-radius: 10px;
			// position: absolute;

			/* .tab-box {
				color: #666;
				background: #fff;
				height: 100rpx;

				.tab {
					flex: 1;
					height: 100%;
				}

				.tab-active {
					color: #333;
					font-size: 36rpx;
					font-weight: 700;

					.fot {
						width: 60rpx;
						height: 4px;
						background: #FF9000;
						margin-top: 10rpx;
					}
				}
			} */
			.share-title {
				height: 100rpx;
				justify-content: space-around;
				font-size: 30rpx;
				font-weight: 600;
				color: #333;

				.share-success {
					text {
						color: #FF9000;
					}
				}
			}


			.data-list {
				background: #fff;
				width: 90%;
				margin: 0 5% 0 5%;

				.list-item {
					// height: 100rpx;
					width: 100%;
					border-bottom: 1px solid #eee;
					justify-content: space-between;

					.item-type {
						font-size: 26rpx;
						color: #333;
					}

					.type-date {
						font-size: 26rpx;
						color: #999;
					}

					.type-red {
						color: #FF9000;
					}

					.share-avatar {
						width: 100rpx;
						height: 100rpx;
						border-radius: 50%;
						margin: 20rpx 20rpx 20rpx 0;
					}


				}

			}
		}

		.sub {
			position: fixed;
			z-index: 3;
			background: #fff;
			height: 80rpx;
			/* #ifdef H5 */
			left: var(--window-left);
			right: var(--window-right);
			bottom: var(--window-bottom);
			/* #endif */
			/* #ifndef H5 */
			left: 0;
			right: 0;
			bottom: 0;
			/* #endif */
			/* padding: 10rpx 0;
			padding-bottom: constant(safe-area-inset-bottom);
			padding-bottom: env(safe-area-inset-bottom); */
			padding: 20rpx 0;
			padding-bottom: calc(constant(safe-area-inset-bottom) + 20rpx);
			padding-bottom: calc(env(safe-area-inset-bottom) + 20rpx);

			button {
				height: 100%;
				margin: 0 10%;
				border: none;
				background: #ff9000;
				border-radius: 80rpx;
				color: #fff;
			}

		}
	}
</style>
